#!/sbin/openrc-run

extra_started_commands="reload"
description_reload="Reload configuration"

: ${conffile:="/etc/pgcat/pgcat.toml"}
command=/usr/sbin/pgcat
command_args="$conffile --no-color $CMD_OPTS"
command_background=yes
: ${command_user:="pgcat"}
: ${command_group:="pgcat"}
pidfile=/run/pgcat/${RC_SVCNAME}

: ${logdir:="/var/log/pgcat"}
: ${output_log:="$logdir/${RC_SVCNAME}.log"}
: ${error_log:="$logdir/${RC_SVCNAME}.log"}

required_files="$conffile"
rc_ulimits="-n ${OPENFILES:-65536}"

start_pre() {
	checkpath --directory --owner "$command_user":"$command_group" "$logdir"
	checkpath --directory --owner "$command_user":"$command_group" "${pidfile%/*}"
}

reload() {
	start-stop-daemon --signal HUP --pidfile "$pidfile"
}
